<template>
  <div>
    <van-nav-bar
      fixed
      title="父组件向子组件传值"
      left-text
      right-text="按钮"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />

    <div class="dateImg" style="margin-top:50px">
      <!-- 父组件: -->
      <div
        :class="{red:i === item.virtualWalletName}"
        @click="datelist(item.virtualWalletName)"
        v-for="(item,index) in list.slice(0,5)"
        :key="index"
      >{{item.virtualWalletName}}</div>
      <!-- 引入子组件 -->
    </div>
    <!-- 父组件向子组件传递一个参数 参数名为inputName -->
    <child :inputName="i"></child>


    <!-- 改变Token数据 -->
    <div style="margin-top:50px;width:100%" @click="Tokentype">
      <van-button type="info">点击改变Token数据</van-button>
    </div>
  </div>
</template>
<script>
import child from "../../components/chldcode";
export default {
  components: {
    child
  },
  data() {
    return {
      name: "",
      list: [],
      i: "USDT"
    };
  },
  created() {
    this.enterLogin();
  },
  methods: {

    // 点击改变token数据
    Tokentype() {
      var newp = JSON.parse(localStorage.getItem("userMsg"));
      newp.phoneNo = "111";
      localStorage.setItem("userMsg", JSON.stringify(newp));
      console.log(newp, 66);
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    onClickRight() {
      this.$router.push({path:'./vue_ref'})
    },
    datelist(num) {
      console.log(num);
      this.i = num;
    },
    enterLogin() {
      let that = this;
      that.$axios.get(that.address.virtualWallet, {}).then(res => {
        if (res.data.code == 200) {
          this.list = res.data.data;
        } else {
        }
      });
    }
  }
};
</script>
<style lang="less" scoped>
.dateImg {
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 14px;
  flex-wrap: wrap;
}
.red {
  color: red;
  border-bottom: 1px solid red;
  padding-bottom: 10px;
}
</style>